from django.shortcuts import render
from django.http import JsonResponse
from django.views import View

from template.serialization.allSerialization import serTest


# Create your views here.

class test(View):
    """

    """

    def get(self, request):
        """
        查询
        """
        #  ---------------- 接收 -----------------
        params = request.GET.dict()
        page = params.pop('page')
        limit = params.pop('limit')
        #  --------------- 处理 ------------------
        st = serTest()
        data = st.select(select_dict=params).values()
        content = st.page(query=data, page=page, limit=limit)
        #  ----------------- 返回 ------------------
        con = {
            'code': 1,
            'data': {
                'list': content,
                'page': page,
                'limit': limit,
                'count': data.count()
            },
            'msg': 'success'
        }
        return JsonResponse(con)

    def post(self, reqiest):
        """
        增加
        """
        pass
